package com.fr.report.web.ui.reg;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.util.Utils;

public class LengthReg extends AbstractReg
{
  public static final String XML_TAG = "LenReg";
  private int minLen = 0;
  private int maxLen = 13;

  public int getMinLen()
  {
    return this.minLen;
  }

  public void setMinLen(int paramInt)
  {
    this.minLen = paramInt;
  }

  public int getMaxLen()
  {
    return this.maxLen;
  }

  public void setMaxLen(int paramInt)
  {
    this.maxLen = paramInt;
  }

  public String toRegText()
  {
    return "^.{" + this.minLen + "," + this.maxLen + "}$";
  }

  public boolean equals(Object paramObject)
  {
    return ((paramObject instanceof LengthReg) && (((LengthReg)paramObject).minLen == this.minLen) && (((LengthReg)paramObject).maxLen == this.maxLen));
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("LenReg"))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("min")) != null)
          this.minLen = Utils.string2Number(str2).intValue();
        if ((str2 = paramXMLableReader.getAttr("max")) != null)
          this.maxLen = Utils.string2Number(str2).intValue();
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if ((this.minLen != 0) || (this.maxLen != 13))
    {
      paramXMLPrintWriter.startTAG("LenReg");
      paramXMLPrintWriter.attr("min", this.minLen);
      paramXMLPrintWriter.attr("max", this.maxLen);
      paramXMLPrintWriter.end();
    }
  }
}